package org.dawning.shop.inventory.rest;

import org.axonframework.commandhandling.gateway.CommandGateway;
import org.dawning.shop.common.commands.inventory.CreateInventoryCommand;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Cc on 2017/6/12.
 */
@RestController
@RequestMapping("inventory")
public class InventoryDomainController {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private CommandGateway commandGateway;

    @RequestMapping("create/{sku}/{amount}/{warnAmount}")
    public String createTest(@PathVariable String sku, @PathVariable Long amount, @PathVariable Long warnAmount){
        commandGateway.send(new CreateInventoryCommand(sku, amount,warnAmount));

        return "{\"aggregateId\":\""+sku+"\"}";
    }

}
